Socket
Socket
Sign inDemoInstall

eslint-compat-utils

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-compat-utils

Provides an API for ESLint custom rules that is compatible with the latest ESLint even when using older ESLint.


Version published
Weekly downloads
2.2M
increased by1.29%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-compat-utils

This package is still in the experimental stage.

Provides an API for ESLint custom rules that is compatible with the latest ESLint even when using older ESLint.

Installation

npm install eslint-compat-utils

Usage

const { getSourceCode } = require("eslint-compat-utils");
module.exports = {
  meta: { /* ... */ },
  create(context) {
    const sourceCode = getSourceCode(context)
    return {
      "Program"(node) {
        const scope = sourceCode.getScope(node);
      },
    };
  },
}

API

getSourceCode(context)

Returns an extended instance of context.sourceCode or the result of context.getSourceCode(). Extended instances can use new APIs such as getScope(node) even with old ESLint.

getCwd(context)

Gets the value of context.cwd, but for older ESLint it returns the result of context.getCwd(). Versions older than v6.6.0 return a value from the result of process.cwd().

getFilename(context)

Gets the value of context.filename, but for older ESLint it returns the result of context.getFilename().

getPhysicalFilename(context)

Gets the value of context.physicalFilename, but for older ESLint it returns the result of context.getPhysicalFilename(). Versions older than v7.28.0 return a value guessed from the result of context.getFilename(), but it may be incorrect.

Keywords

FAQs

Package last updated on 16 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc